home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / easyproc2.lha / EasyProcess / launch / FlushProcs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  1.1 KB  |  62 lines

  1. #include "Launch.h"
  2. #include "LaunchPriv.h"
  3.  
  4.  
  5. /*
  6.  *    NAME
  7.  *        FlushProcesses -- free all children that are dead.
  8.  *
  9.  *    SYNOPSIS
  10.  *        FlushProcesses ()
  11.  *
  12.  *        void FlushProcesses (void);
  13.  *
  14.  *    DESCRIPTION
  15.  *        Scan the process pair list and if the parent is te current
  16.  *        process and the child is dead, it removes the pair and frees
  17.  *        the memory.
  18.  *
  19.  *        After the scan, we check if the current process is still a
  20.  *        parent.  If not, we free its signal bit.
  21.  *
  22.  *        We then check if the list is empty and free it.
  23.  *
  24.  *    INPUT
  25.  *        None.
  26.  *
  27.  *    OUTPUT
  28.  *        None.
  29.  *
  30.  *    HISTORY
  31.  *        1992/09/07    Pierre Baillargeon        Creation
  32.  */
  33.  
  34. void FlushProcesses (void)
  35. {
  36.     struct ProcPair *pp;
  37.     struct Process *Proc;
  38.     LONG Bit;
  39.  
  40.     Bit = -1L;
  41.     Proc = (struct Process *)FindTask (NULL);
  42.  
  43.     Forbid ();
  44.     if (NULL != ProcPairList)
  45.     {
  46.         for (pp = (struct ProcPair *)ProcPairList->lh_Head; pp->pp_Node.ln_Succ; pp = (struct ProcPair *)pp->pp_Node.ln_Succ)
  47.         {
  48.             if (Proc == pp->pp_Parent && NULL == pp->pp_ChildEntry)
  49.             {
  50.                 Bit = pp->pp_ParentBit;
  51.                 Remove (&pp->pp_Node);
  52.                 FreeMem (pp, sizeof (struct ProcPair));
  53.             }
  54.         }
  55.     }
  56.  
  57.     FreeParentSignal (Bit);
  58.     FreeProcPairList ();
  59.  
  60.     Permit ();
  61. }
  62.